import request from '@/http';
import { ApiResponse } from '@/types/account';
import { JudgeServerResponse, UpdateJudgeServerRequest } from '../types/judgeServer';

enum Url {
  judgeServer = '/api/judge_server/',
}

export const judgeServerService = {
  /**
   * 获取评测服务器列表
   */
  async getJudgeServers(): Promise<ApiResponse<JudgeServerResponse>> {
    const response = await request.get(Url.judgeServer);
    return response.data;
  },

  /**
   * 删除评测服务器
   * @param id 服务器ID
   */
  async deleteJudgeServer(id: number): Promise<ApiResponse<null>> {
    const response = await request.delete(`${Url.judgeServer}${id}/`);
    return response.data;
  },

  /**
   * 更新评测服务器状态
   * @param id 服务器ID
   * @param data 更新请求数据
   */
  async updateJudgeServer(id: number, data: UpdateJudgeServerRequest): Promise<ApiResponse<null>> {
    const response = await request.patch(`${Url.judgeServer}${id}/`, data);
    return response.data;
  },
}; 